<?php
namespace Home\Controller;
use Think\Controller;
import("Common.Common.Tools");
class GuestbookController extends Controller {

    function showlist(){
        $guestbook=new \Model\GuestbookModel();
        $info=$guestbook->order('id desc')->select();
        $this->assign('info',$info);
        $link=M('Link');
        $link_info=$link->select();
        $this->assign('link_info',$link_info);
        $about=M('About');
        $about=$about->find();
        $this->assign('about',$about);
        $this->display();
    }


    function add(){
        $guestbook=new \Model\GuestbookModel();
        if(!empty($_POST)){
            $z=$guestbook->add($_POST);
            if($z){
                $this->redirect('showlist',array(),0,'留言成功');
            }else{
                $this->redirect('showlist',array(),1,'<h1>留言失败</h1>');

            }
        }else{
            $this->redirect('showlist', array(), 1, '<h1>留言失败</h1>');

        }
        $info=$guestbook->order('id desc')->select();
        $this->assign('info',$info);
        $page=getPage(10,2);
        $this->assign('page',$page->show());
        $this->display();
    }

}